import { log_mongoDB } from '../../../../../../../../../../conect_mongoDB_class_laugh_node';
import { spacename_user } from '../../../../../../user/DataDefine/sourceData';
import {
  prop_type_target_id,
  req_info_type,
} from '../../../../../Classes/cla_req_info_type';
import { spacename_log_type } from '../DataDefine/sourceData';

/**
 * 类型 日志 路径
 *
 * path -->
 *
 * log_type_user_${uni.belong_user}\_${uni.sort}\_${uni.id}
 */
export function get_path_type_log_cur_target(cur_info: req_info_type) {
  return `${spacename_log_type}_${cur_info[prop_type_target_id]}`;
}

/**
 * 类型 日志 路径
 *
 * path -->
 *
 * log_type_user_${cur_user_id}_${target_sort}_${target_id}
 */
export function get_path_type_log_cur_target_id(
  cur_user_id: string,
  target_sort: string,
  target_id: string
) {
  return `${spacename_log_type}_${spacename_user}_${cur_user_id}_${target_sort}_${target_id}`;
}

/**
 * log 数据库中
 *
 * 类型 日志 表
 *
 * log_type_user_${uni.belong_user}\_${uni.sort}\_${uni.id}
 */
export function get_db_type_log_cur_target(cur_info: req_info_type) {
  return log_mongoDB.collection(get_path_type_log_cur_target(cur_info));
}
